<%--
  @author Supun Nimesh Karunathilaka
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script src="${pageContext.request.contextPath}/lib/validation/jquery.validate.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/lib/validation/cmxforms.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $("#change-password").validate({
            rules: {
                password: {
                    required: true
                },
                newPassword:{
                    required: true,
                    minlength:6
                },
                confirm_password: {
                    equalTo: "#newPassword"
                }
            },
            messages: {
                password: {
                    required: "<br/>" + "Please enter your password."
                },
                newPassword:{
                    required: "<br/>" + "Please enter your new password",
                    minlength: "<br/>" + "Your password must be at least 6 characters long."

                },
                confirm_password: {
                    equalTo: "<br/>" + "New Password and the Confirm Password should be the same."
                }
            }
        });
    });
</script>
<div id="change-password-div">
    <%--<h2><s:label value="%{getText('my_profile.label')}"/></h2>--%>

    <fieldset class="fieldset-style">
        <%--<legend><s:label value="%{getText('change_password.label')}"/></legend>--%>
            <legend><h2><s:label value="%{getText('change_password.label')}"/></h2></legend>
        <s:form id="change-password" name="change-password" method="POST">
            <table>
                <tr>
                    <td colspan="2" class="left-align">
                        <div class="action-msg"><s:actionmessage/></div>
                        <div class="action-err"><s:actionerror/></div>
                    </td>
                </tr>
                <tr>
                    <td class="left-align"><s:label value="%{getText('user_name.label')}"/></td>
                    <td class="right-align"><s:textfield name="username" id="username" disabled="true"/></td>
                </tr>
                <tr>
                    <td class="left-align"><s:label value="%{getText('password.label')}"
                                                    cssClass="mandatory-field"/></td>
                    <td class="right-align"><s:password name="password" id="password"/></td>
                </tr>
                <tr>
                    <td class="left-align"><s:label value="%{getText('new_password.label')}"
                                                    cssClass="mandatory-field"/></td>
                    <td class="right-align"><s:password name="newPassword" id="newPassword"/></td>
                </tr>
                <tr>
                    <td class="left-align"><s:label value="%{getText('confirm_password.label')}"/></td>
                    <td class="right-align"><s:password name="retypePassword" id="confirm_password"/></td>
                </tr>
                <tr>
                        <%--   <s:if test="#session.userGroup=='slc'">
                             <td colspan="2" class="right-align"><s:submit value="%{getText('change_password.label')}" action="changePasswordApplicant"/></td>
                        </s:if>
                        <s:else>--%>
                    <td colspan="2" class="right-align"><s:submit value="%{getText('change_password.label')}"
                                                                  action="changePassword"/></td>
                        <%--</s:else>--%>


                </tr>
            </table>
        </s:form>
    </fieldset>
   <fieldset class="fieldset-style">
        <legend><h2><s:label value="%{getText('change_pref_language.label')}"/></h2></legend>
        <s:form id="change-preferred-language" name="change-preferred-language" method="POST">
            <table>
                <tr>
                    <td class="left-align"><s:label value="%{getText('preferred_language.label')}"/></td>
                    <td>
                     <%--   <s:select
                                list="#@java.util.LinkedHashMap@{'si':'සිංහල','en':'ENGLISH','ta':'தமிழ்'}"
                                name="prefLanguage" id="prefLanguage" value="%{#session.WW_TRANS_I18N_LOCALE.language}"
                                cssClass="width-180-px"/>--%>
                         <s:select
                                 list="#@java.util.LinkedHashMap@{'si':'සිංහල','en':'ENGLISH','ta':'தமிழ்'}"
                                 name="prefLanguage" id="prefLanguage" cssClass="width-180-px"/>
                    </td>
                </tr>
                <tr>
                    <s:if test="#session.userGroup=='slc'">
                        <td colspan="2" class="right-align"><s:submit value="%{getText('change_pref_language.label')}"
                                                                      action="changePreferredLanguageByApplicant"/></td>

                    </s:if>
                    <s:else>
                        <td colspan="2" class="right-align"><s:submit value="%{getText('change_pref_language.label')}"
                                                                      action="changePreferredLanguage"/></td>

                    </s:else>

                </tr>
            </table>
        </s:form>
    </fieldset>
</div>